<?php
// Post Template - Single Post View
$post = get_post($_GET['file']);
if (!$post) {
    header('Location: /');
    exit;
}
?>

<?php include __DIR__ . '/header.php'; ?>

    <main>
        <article>
            <h2><?= htmlspecialchars($post['title']) ?></h2>
            <p class="meta">Posted on <?= date('F j, Y', strtotime($post['created_at'])) ?></p>
            
            <?php if (pathinfo($post['filename'], PATHINFO_EXTENSION) === 'html'): ?>
                <?= $post['content'] ?>
            <?php else: ?>
                <pre><?= htmlspecialchars($post['content']) ?></pre>
            <?php endif; ?>
        </article>
    </main>

    <footer>
        <p>&copy; <?= date('Y') ?> Codeless Blog</p>
    </footer>
</body>
</html>
